package com.speedricemanager.activity.home.registermodepart;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.speedricemanager.R;
import com.speedricemanager.activity.home.registermodepart.presenter.RegisterModePartPersenter;
import com.speedricemanager.activity.home.registermodepart.view.RegisterModePart_Inter;
import com.speedricemanager.interfaces.DialogSuccess;
import com.speedricemanager.other.base.BaseAty;
import com.speedricemanager.other.utils.PickerViewTime;
import com.vondear.rxtools.view.RxTitle;

import java.math.BigDecimal;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;


/**
 * Created by 李征 on 2017/12/18.
 */

public class RegisterModePart extends BaseAty implements RegisterModePart_Inter {

    int tmid;
    @InjectView(R.id.rx_title)
    RxTitle rxTitle;
    @InjectView(R.id.dtepingtai)
    TextView dtepingtai;
    @InjectView(R.id.dtehuanjing)
    TextView dtehuanjing;
    @InjectView(R.id.dtedianfukuan)
    TextView dtedianfukuan;
    @InjectView(R.id.dtedianzikuan)
    TextView dtedianzikuan;
    @InjectView(R.id.buqujifei)
    Button buqujifei;
    @InjectView(R.id.dtedianzikuaner)
    TextView dtedianzikuaner;
    @InjectView(R.id.layoutdiancikuan)
    LinearLayout layoutdiancikuan;
    @InjectView(R.id.telayoutaddtioajian)
    LinearLayout telayoutaddtioajian;
    @InjectView(R.id.dtejiaodanyaoqiu)
    TextView dtejiaodanyaoqiu;
    @InjectView(R.id.buqujdyq)
    Button buqujdyq;
    @InjectView(R.id.dtejiaodanyaoqiuer)
    TextView dtejiaodanyaoqiuer;
    @InjectView(R.id.layoutjiedanyq)
    LinearLayout layoutjiedanyq;
    @InjectView(R.id.dtejiaodanliucheng)
    TextView dtejiaodanliucheng;
    @InjectView(R.id.buqujdlc)
    Button buqujdlc;
    @InjectView(R.id.dtejiaodanliuchenger)
    TextView dtejiaodanliuchenger;
    @InjectView(R.id.layoutjiedanlc)
    LinearLayout layoutjiedanlc;
    @InjectView(R.id.dtejiedantiaojian)
    TextView dtejiedantiaojian;
    @InjectView(R.id.buqujdtj)
    Button buqujdtj;
    @InjectView(R.id.dtejiedantiaojianer)
    TextView dtejiedantiaojianer;
    @InjectView(R.id.layoutjiedantj)
    LinearLayout layoutjiedantj;
    @InjectView(R.id.shezirenwushijian)
    TextView shezirenwushijian;
    @InjectView(R.id.startime)
    TextView startime;
    @InjectView(R.id.enttime)
    TextView enttime;
    @InjectView(R.id.dtezujin)
    TextView dtezujin;
    @InjectView(R.id.buquzj)
    Button buquzj;
    @InjectView(R.id.dtezujiner)
    TextView dtezujiner;
    @InjectView(R.id.dtezhuhaobaozhengjiin)
    TextView dtezhuhaobaozhengjiin;
    @InjectView(R.id.layoutaddid)
    LinearLayout layoutaddid;
    @InjectView(R.id.tongyishenqing)
    Button tongyishenqing;
    @InjectView(R.id.jujueshenqing)
    Button jujueshenqing;
    @InjectView(R.id.tiqianjieshu)
    Button tiqianjieshu;
    @InjectView(R.id.zhuhbaozhengjin)
    EditText zhuhbaozhengjin;
    @InjectView(R.id.fuhaobangzhengjin)
    EditText fuhaobangzhengjin;
    @InjectView(R.id.jdrbzj)
    TextView jdrbzj;
    @InjectView(R.id.layoutzujin)
    LinearLayout layoutzujin;
    @InjectView(R.id.layoutbaozhengjin)
    LinearLayout layoutbaozhengjin;
    @InjectView(R.id.mobanname)
    TextView mobanname;
    @InjectView(R.id.shenfen)
    TextView shenfen;

    private RegisterModePartPersenter registerModePartPersenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.registermodepart);
        ButterKnife.inject(this);
        setTitle(rxTitle);
        registerModePartPersenter = new RegisterModePartPersenter(this, this);
        tmid = getIntent().getIntExtra("tmid", 0);
        registerModePartPersenter.getMoluldInfo();
    }

    @Override
    public int getTmid() {
        return tmid;
    }

    @Override
    public TextView dtepingtai() {
        return dtepingtai;
    }

    @Override
    public TextView dtehuanjing() {
        return dtehuanjing;
    }

    @Override
    public TextView dtedianfukuan() {
        return dtedianfukuan;
    }

    @Override
    public TextView dtedianzikuan() {
        return dtedianzikuan;
    }

    @Override
    public TextView dtedianzikuaner() {
        return dtedianzikuaner;
    }

    @Override
    public LinearLayout layoutdiancikuan() {
        return layoutdiancikuan;
    }

    @Override
    public LinearLayout telayoutaddtioajian() {
        return telayoutaddtioajian;
    }

    @Override
    public TextView dtejiaodanyaoqiu() {
        return dtejiaodanyaoqiu;
    }

    @Override
    public TextView dtejiaodanyaoqiuer() {
        return dtejiaodanyaoqiuer;
    }

    @Override
    public LinearLayout layoutjiedanyq() {
        return layoutjiedanyq;
    }

    @Override
    public TextView dtejiaodanliucheng() {
        return dtejiaodanliucheng;
    }

    @Override
    public TextView dtejiaodanliuchenger() {
        return dtejiaodanliuchenger;
    }

    @Override
    public LinearLayout layoutjiedanlc() {
        return layoutjiedanlc;
    }

    @Override
    public TextView dtejiedantiaojian() {
        return dtejiedantiaojian;
    }

    @Override
    public TextView dtejiedantiaojianer() {
        return dtejiedantiaojianer;
    }

    @Override
    public LinearLayout layoutjiedantj() {
        return layoutjiedantj;
    }

    @Override
    public TextView shezirenwushijian() {
        return shezirenwushijian;
    }

    @Override
    public TextView startime() {
        return startime;
    }

    @Override
    public TextView enttime() {
        return enttime;
    }

    @Override
    public TextView dtezujin() {
        return dtezujin;
    }

    @Override
    public TextView dtezujiner() {
        return dtezujiner;
    }

    @Override
    public TextView dtezhuhaobaozhengjiin() {
        return dtezhuhaobaozhengjiin;
    }

    @Override
    public LinearLayout layoutaddid() {
        return layoutaddid;
    }

    @Override
    public TextView jdrbzj() {
        return jdrbzj;
    }

    @Override
    public Button tongyishenqing() {
        return tongyishenqing;
    }

    @Override
    public Button jujueshenqing() {
        return jujueshenqing;
    }

    @Override
    public Button tiqianjieshu() {
        return tiqianjieshu;
    }

    @Override
    public EditText zhuhbaozhengjin() {
        return zhuhbaozhengjin;
    }

    @Override
    public EditText fuhaobangzhengjin() {
        return fuhaobangzhengjin;
    }

    @Override
    public int gettagstu() {
        return i;
    }

    @Override
    public String getjujue() {
        return jujueyuanyin;
    }

    @Override
    public Button buqujifei() {
        return buqujifei;
    }

    @Override
    public Button buqujdyq() {
        return buqujdyq;
    }

    @Override
    public Button buqujdlc() {
        return buqujdlc;
    }

    @Override
    public Button buqujdtj() {
        return buqujdtj;
    }

    @Override
    public Button buquzj() {
        return buquzj;
    }

    @Override
    public LinearLayout layoutbaozhengjin() {
        return layoutbaozhengjin;
    }

    @Override
    public TextView mobanname() {
        return mobanname;
    }

    @Override
    public TextView shenfen() {
        return shenfen;
    }

    String jujueyuanyin;
    int i = 0;

    @OnClick({R.id.buqujifei, R.id.buqujdyq, R.id.buqujdlc, R.id.buqujdtj, R.id.buquzj, R.id.tongyishenqing, R.id.jujueshenqing, R.id.tiqianjieshu, R.id.startime, R.id.enttime})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.buqujifei:
                editAlert("确定要修改垫资款吗?", new DialogSuccess() {
                    @Override
                    public void option(String password) {
                        layoutdiancikuan.setVisibility(View.VISIBLE);
                        dtedianzikuaner.setText(new BigDecimal(password).floatValue() + "");
                    }
                });
                break;
            case R.id.buqujdyq:
                editAlert("确定要修改接单要求吗?", new DialogSuccess() {
                    @Override
                    public void option(String password) {
                        layoutjiedanyq.setVisibility(View.VISIBLE);
                        dtejiaodanyaoqiuer.setText(password);
                    }
                });
                break;
            case R.id.buqujdlc:
                editAlert("确定要修改接单流程吗?", new DialogSuccess() {
                    @Override
                    public void option(String password) {
                        layoutjiedanlc.setVisibility(View.VISIBLE);
                        dtejiaodanliuchenger.setText(password);
                    }
                });
                break;
            case R.id.buqujdtj:
                editAlert("确定要修改接单流程吗?", new DialogSuccess() {
                    @Override
                    public void option(String password) {
                        layoutjiedantj.setVisibility(View.VISIBLE);
                        dtejiedantiaojianer.setText(password);
                    }
                });
                break;
            case R.id.buquzj:
                editAlert("确定要修改租金吗?", new DialogSuccess() {
                    @Override
                    public void option(String password) {
                        layoutzujin.setVisibility(View.VISIBLE);
                        dtezujiner.setText(new BigDecimal(password).floatValue() + "");
                    }
                });
                break;
            case R.id.tongyishenqing:
                if (zhuhbaozhengjin.getText().toString().equals("")) {
                    errorAlert("主账号保证金不能为空");
                } else if (fuhaobangzhengjin.getText().toString().equals("")) {
                    errorAlert("副账号保证金不能为空");
                } else {
                    i = 2;
                    registerModePartPersenter.AuditTaskMoulds();
                }
                break;
            case R.id.jujueshenqing:
                if (zhuhbaozhengjin.getText().toString().equals("")) {
                    errorAlert("主账号保证金不能为空");
                } else if (fuhaobangzhengjin.getText().toString().equals("")) {
                    errorAlert("副账号保证金不能为空");
                } else {
                    editAlert("请填写拒绝原因", new DialogSuccess() {
                        @Override
                        public void option(String password) {
                            jujueyuanyin = password;
                            i = 3;
                            registerModePartPersenter.AuditTaskMoulds();
                        }
                    });
                }
                break;
            case R.id.tiqianjieshu:
                if (zhuhbaozhengjin.getText().toString().equals("")) {
                    errorAlert("主账号保证金不能为空");
                } else if (fuhaobangzhengjin.getText().toString().equals("")) {
                    errorAlert("副账号保证金不能为空");
                } else {
                    registerModePartPersenter.overMould();
                }
                break;
            case R.id.startime:
                PickerViewTime.getTData(this, 0, startime);
                break;
            case R.id.enttime:
                PickerViewTime.getTData(this, 0, enttime);
                break;
        }
    }
}
